package cn.nfwx.tv.db;

import android.arch.persistence.room.ColumnInfo;
import android.arch.persistence.room.Entity;
import android.arch.persistence.room.ForeignKey;
import android.arch.persistence.room.Ignore;
import android.arch.persistence.room.Index;
import android.arch.persistence.room.PrimaryKey;

import static android.arch.persistence.room.ForeignKey.CASCADE;


@Entity(tableName = "tb_ts", foreignKeys = @ForeignKey(entity = DownProgramModel.class,
        parentColumns = "id",
        childColumns = "program_id", onDelete = CASCADE), indices = @Index(value = {"program_id"}))
public class TsProgramModel {

    public TsProgramModel(String m3u8Url, String tsUrl, String localPath, int stats, String action) {
        this.m3u8Url = m3u8Url;
        this.tsUrl = tsUrl;
        this.localPath = localPath;
        this.stats = stats;
        this.action = action;
    }

    @Ignore
    public TsProgramModel() {
    }

    public static final int STATS_NO = 0;
    public static final int STATS_DOWNING = 1;
    public static final int STATS_SUCCESS = 2;
    public static final int STATS_FAIL = 3;
    public static final int STATS_NO_NETWORK = 4;

    @PrimaryKey(autoGenerate = true)
    private int id;

    @ColumnInfo(name = "m3u8Url")
    private String m3u8Url;

    @ColumnInfo(name = "tsUrl")
    private String tsUrl;

    @ColumnInfo(name = "localPath")
    private String localPath;

    @ColumnInfo(name = "action")
    private String action;

    /**
     * 0、未开始 1、正在下载 2、下载完成
     */
    @ColumnInfo(name = "stats")
    private int stats;

    @ColumnInfo(name = "program_id")
    private long programId;


    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getM3u8Url() {
        return m3u8Url;
    }

    public void setM3u8Url(String m3u8Url) {
        this.m3u8Url = m3u8Url;
    }

    public String getTsUrl() {
        return tsUrl;
    }

    public void setTsUrl(String tsUrl) {
        this.tsUrl = tsUrl;
    }

    public String getLocalPath() {
        return localPath;
    }

    public void setLocalPath(String localPath) {
        this.localPath = localPath;
    }

    public int getStats() {
        return stats;
    }

    public void setStats(int stats) {
        this.stats = stats;
    }

    public String getAction() {
        return action;
    }

    public void setAction(String action) {
        this.action = action;
    }

    @Override
    public String toString() {
        return "TsProgramModel{" +
                "id=" + id +
                ", m3u8Url='" + m3u8Url + '\'' +
                ", tsUrl='" + tsUrl + '\'' +
                ", localPath='" + localPath + '\'' +
                ", action='" + action + '\'' +
                ", stats=" + stats +
                ", programId=" + programId +
                '}';
    }

    public long getProgramId() {
        return programId;
    }

    public void setProgramId(long programId) {
        this.programId = programId;
    }
}
